package com.example.wtt.exception;

import com.example.wtt.common.Result;
import org.springframework.web.bind.annotation.ExceptionHandler;
import org.springframework.web.bind.annotation.RestControllerAdvice;

@RestControllerAdvice
public class GlobalExceptionHandler {
    // 告诉其处理什么异常
    @ExceptionHandler(ServiceException.class)  // 业务异常
    public Result handle(ServiceException se){
        return Result.error(se.getCode(), se.getMessage());
    }
}
